Skip to content

Update UnrealEngine.gitignore #4500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

wdhongtw
Copy link

@wdhongtw wdhongtw commented Sep 4, 2024

Unreal Engine supports project file generation for VSCode. Enhance Unreal ignore file for VSCode accordingly.

Reasons for making this change:

I'm an ordinary developer who is using Unreal Engine recently.

This PR makes sure that all files generated by Unreal Engine, which contains user/machine specific contents,
is ignored by this ignore template out of the box.

.vscode folder will contain a bunch of compile commands, which consist of machine specific paths.

For example, in .vscode\compileCommands_<ProjectName>.json, there will be

	{
		"file": "C:\\Users\\<username>\\Unreal Projects\\PlayUnreal\\Source\\PlayUnreal\\PlayUnreal.cpp",
		"arguments": [
			"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\Hostx64\\x64\\cl.exe",
			"@C:\\Users\\<username>\\Unreal Projects\\PlayUnreal\\.vscode\\compileCommands_PlayUnreal\\PlayUnreal.1.rsp"
		],
		"directory": "C:\\Program Files\\Epic Games\\UE_5.4\\Engine\\Source"
	}

Also, in <ProjectName>.code-workspace

			{
				"name": "Launch <ProjectName> (Shipping)",
				"request": "launch",
				"program": "C:\\Users\\<username>\\Unreal Projects\\<ProjectName>\\Binaries\\Win64\\UnrealGame-Win64-Shipping.exe",
				"preLaunchTask": "<ProjectName> Win64 Shipping Build",
				"args": [
				],
				"cwd": "C:\\Program Files\\Epic Games\\UE_5.4",
				"stopAtEntry": false,
				"console": "integratedTerminal",
				"type": "cppvsdbg",
				"visualizerFile": "C:\\Program Files\\Epic Games\\UE_5.4\\Engine\\Extras\\VisualStudioDebugging\\Unreal.natvis",
				"sourceFileMap": {
					"D:\\build\\++UE5\\Sync": "C:\\Program Files\\Epic Games\\UE_5.4"
				}
			}

If we create a new C++ project from latest version of Unreal Engine (5.4), .vscode is ignored
by the generated .gitignore file. (Although *.code-workspace is still not included.)

Links to documentation supporting these rule changes:

Unreal Engine supports project file generation for VSCode.
Enhance Unreal ignore file for VSCode accordingly.
@wdhongtw
Copy link
Author

wdhongtw commented Sep 5, 2024

As a reference, the following is the generated default .gitignore file
when creating a new Unreal Engine project throught Unreal Engine Editor (Unreal Engine Editor for Windows v5.4).

Binaries
DerivedDataCache
Intermediate
Saved
.vscode
.vs
*.VC.db
*.opensdf
*.opendb
*.sdf
*.sln
*.suo
*.xcodeproj
*.xcworkspace

@wirecat
Copy link
Collaborator

wirecat commented May 23, 2025

We get this quite a bit, but that is incorrect. The .vscode folder is the workspace folder and is intended to house workspace configuration/settings. We don't want to globally ignore this folder for that reason.

Please read more about the workspace folder here: https://code.visualstudio.com/docs/configure/settings#_workspace-settings

Could you please remove the entry for .vscode?

@wdhongtw
Copy link
Author

It's unfortunate that UE places generated contents in the .vscode folder,
while those contents are machine-specific.

Based on the design goal you mentioned, maybe we can reduce the impact by
explicitly listing the files and folders in .vscode that are generated by UE.

How do you think about this approach? :D

diff --git a/UnrealEngine.gitignore b/UnrealEngine.gitignore
index 6e0d95f..f6df498 100644
--- a/UnrealEngine.gitignore
+++ b/UnrealEngine.gitignore
@@ -1,6 +1,10 @@
 # Visual Studio 2015 user specific files
 .vs/
 
+# Generated machine-specific settings and commands
+.vscode/c_cpp_properties.json
+.vscode/compileCommands*
+
 # Compiled Object files
 *.slo
 *.lo
@@ -34,6 +38,7 @@
 # These project files can be generated by the engine
 *.xcodeproj
 *.xcworkspace
+*.code-workspace
 *.sln
 *.suo
 *.opensdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants